<?php
namespace App\library\services\lib;


use App\library\services\BaseServices;

class Sms extends BaseServices
{

    /**
     * Author:Yingbo Sun
     * 短信包发送验证码
     * @param $phone
     * @param $code
     */
    public static function sendSms($phone,$code)
    {
        $statusStr = array(
            "0" => "短信发送成功",
            "-1" => "参数不全",
            "-2" => "服务器空间不支持,请确认支持curl或者fsocket，联系您的空间商解决或者更换空间！",
            "30" => "密码错误",
            "40" => "账号不存在",
            "41" => "余额不足",
            "42" => "帐户已过期",
            "43" => "IP地址限制",
            "50" => "内容含有敏感词"
        );
        $smsapi =  config('setting.Sms.smsapi');
        $user =  config('setting.Sms.user'); //短信平台帐号
        $password = config('setting.Sms.pass');
        $pass = md5("$password"); //短信平台密码
        $content="您的验证码是：{$code}，有效期60秒";//要发送的短信内容
        $phone = "$phone";//要发送短信的手机号码
        $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
        $result =file_get_contents($sendurl) ;
        if ($result == 0){
            return self::success($statusStr[$result]);
        }else{
            return self::fail($statusStr[$result]);
        }
    }
}
